import React from 'react'
import ReactDOM from 'react-dom'
import { ConfigProvider } from 'antd' 
import zhCN from 'antd/lib/locale/zh_CN'
import { HashRouter as Router, Redirect, Route, Switch } from 'react-router-dom'
import { Provider } from 'react-redux'
import store from './store'
import App from './App'
import { whiteList } from './routes'

import 'antd/dist/antd.less'

import './utils/permission'

ReactDOM.render(
  <Provider store={store}>
    <Router>
      <ConfigProvider locale={zhCN}>
        <Switch>
          <Redirect to="/admin" from="/" exact />
          {
            whiteList.map(route => (
              <Route key={route.path} path={route.path} component={route.component} />
            ))
          }
          <Route path="/admin" component={App} />
          <Redirect to="/404" />
        </Switch>
      </ConfigProvider>
    </Router>
  </Provider>,
  document.getElementById('root')
)
